package ldh.text.util;


import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;

public class ClipboardUtil {

    public static void setContent(String label, String content) {
        Clipboard clipboard = Clipboard.getSystemClipboard();
        ClipboardContent clipboardContent = new ClipboardContent();
        clipboardContent.putString(label + content);
        clipboard.setContent(clipboardContent);
    }

    public static boolean isCopy(String label) {
        Clipboard clipboard = Clipboard.getSystemClipboard();
        String content = clipboard.getString();
        return content != null && content.startsWith(label);
    }

    public static String getContent(String label) {
        Clipboard clipboard = Clipboard.getSystemClipboard();
        String content = clipboard.getString();
        if (content != null && content.startsWith(label)) {
            return content.substring(label.length());
        }
        return null;
    }
}
